import BaseTable from "@/components/BaseTable";
import type { BaseTableProps } from "@/components/BaseTable";
import { Button } from "antd";
import moment from "moment";
import type { TableListItem } from "./index";

const tableListDataSource: TableListItem[] = [];
const creators = ["付小小", "曲丽丽", "林东东", "陈帅帅", "兼某某"];
const columns = [
  {
    title: "标题",
    dataIndex: "name",
    align: "center"
  },
  {
    title: "申请时间",
    dataIndex: "startTime",
    align: "center"
  },
  {
    title: "内容",
    dataIndex: "content",
    align: "center"
  },
  {
    title: "发布者",
    dataIndex: "creators",
    align: "center"
  },
  {
    title: "操作",
    key: "option",
    valueType: "option",
    render: () => [
      <Button key="delete" danger type="link">
        拒绝
      </Button>,
      <Button key="edit" type="link" style={{ marginLeft: "10px" }}>
        同意
      </Button>
    ],
    align: "center"
  }
];
for (let i = 0; i < 30; i += 1) {
  tableListDataSource.push({
    key: i,
    name: `标题${i + 1}`,
    content: "简介",
    startTime: moment(new Date()).format("YYYY/MM/DD HH:mm"),
    creators: creators[Math.floor(Math.random() * creators.length)]
  });
}

const News: React.FC = () => {
  const getTableProps: () => BaseTableProps<TableListItem> = () => ({
    columns,
    dataSource: tableListDataSource
  });
  return <BaseTable {...getTableProps()} />;
};
export default News;
